package day2Arr;

public class Demo08Array {
    public static void main(String[] args) {
        // 数据类型[] 变量名 = new  数据类型[元素个数或者数组长度];
        // js: let arr1 = new Array(3); ===> [ , , ]; let arr1 = [];
        // ts: cost arr1:number[] = []

        String[] arr1 = new String[3]; // String 类型的默认值是 null
        Byte[] arr2 = new Byte[3]; // byte short int long 类型的默认值是 0
        Float[] arr3 = new Float[3]; // float double 类型的默认值是 0.0
        char[] arr4 = new char[3]; // char 类型的默认值是 空格  '\u0000'
        Test[] arr5 = new Test[3]; // 引用数据类型的默认值是 null
        // arr5[0].run();

        arr1[0] = "你好啊";
        arr1[1] = "我是赛利亚";
        arr1[2] = "毒奶粉与勇士";

        System.out.println(arr1.length);
        System.out.println(arr1);
        System.out.println("arr1[0]=" + arr1[0]);
        System.out.println("arr1[1]=" + arr1[1]);
        System.out.println("arr1[2]=" + arr1[2]);
        // System.out.println("arr[3]=" + arr1[3]); // 数组索引越界异常

        System.out.println("arr5[0]=" + arr5[0]);
        System.out.println("arr5[1]=" + arr5[1]);
        System.out.println("arr5[2]=" + arr5[2]);
        System.out.println("结束了");
    }
}

class Test {
    private String num;

    public void run() {
        System.out.println("快跑");
    }
}